package com.example.utils;


public class JsonResult {
	//
	public static final int SUCCESS = 1;
	public static final int ERROR = 500;

	/**
	 * 状态
	 */
	private int status;
	/**
	 * 对应状态的消息
	 */
	private String message;
	/**
	 * 具体业务数据
	 */
	private Object data;

	/**
	 * 当前登录身份
	 * 0 是 admin超级管理员  1 是代理商(供应商)  2 是普通员工 3是维修人员
	 */
	private Object roleType;
	/**
	 * 登录人id
	 */
	private Object loginId;

	/**
	 * 此构造方法应用于data为null的场景
	 */
	public JsonResult() {
		this.status = SUCCESS;
		this.message = "请求成功";
	}

	/**
	 * 有业务返回时调用此方法
	 */
	public JsonResult(Object data) {
		this();
		this.data = data;
	}

	public JsonResult(int status, Object data) {
		this();
		this.status = status;
		this.data = data;
	}

	public JsonResult(int status, Object data, Object roleType, Object loginId) {
		this();
		this.status = status;
		this.data = data;
		this.roleType = roleType;
		this.loginId = loginId;
	}


	/**
	 * 出现异常以后ControllerExceptionHandler调用此方法封装异常信息
	 */
	public JsonResult(ExceptionUtil e) {

		this.status = ERROR;
		this.message = e.getMessage();
	}

	public Object getRoleType() {
		return roleType;
	}

	public void setRoleType(Integer roleType) {
		this.roleType = roleType;
	}

	public int getStatus() {
		return status;
	}


	public String getMessage() {
		return message;
	}


	public Object getData() {
		return data;
	}

	public Object getLoginId() {
		return loginId;
	}

	public void setLoginId(Object loginId) {
		this.loginId = loginId;
	}
}
